import { defineStore } from 'pinia'
// import { useMenuNavApi } from '@/api/sys/menu'
// import { generateRoutes, constantMenu } from '@/router'
import type { RouteRecordRaw } from 'vue-router'

export const useRouterStore = defineStore('routerStore', {
    state: () => ({
		// menuRoutes: [] as RouteRecordRaw[],
        menuRoutes: [
            {
                id: 1000,
                name: '组件演示',
                url: null,
                openStyle: 0,
                icon: 'icon-windows',
                children: [
                    {
                        id: 1001,
                        name: 'Icon 图标',
                        url: 'demo/icons/index',
                        openStyle: 0,
                        icon: 'icon-unorderedlist'
                    },
                    {
                        id: 1002,
                        name: '表单设计器',
                        url: 'demo/formDesign/form',
                        openStyle: 0,
                        icon: 'icon-unorderedlist'
                    },
                ]
            }
        ],
		routes: [] as RouteRecordRaw[]
    }),
    actions: {
		// async getMenuRoutes() {
		// 	const { data } = await useMenuNavApi()
		// 	const routes = generateRoutes(data)

		// 	this.menuRoutes.push(...routes)

		// 	// 常量菜单
		// 	const constantRoutes = generateRoutes(constantMenu)
		// 	this.menuRoutes.push(...constantRoutes)

		// 	return this.menuRoutes
		// },
		setRoutes(routers: RouteRecordRaw[]) {
			this.routes = routers
		}
	}
})